/**
 * 标准分页结果类
 */
export class StandardPagination<T> {
  constructor(
    public readonly data: T[],
    public readonly page: number,
    public readonly pageSize: number,
    public readonly total: number,
    public readonly totalPage: number,
  ) {}
}

/**
 * 创建标准分页对象
 */
export function createStandardPaginationObject<T>({
  items,
  totalItems,
  currentPage,
  limit,
}: {
  items: T[]
  totalItems?: number
  currentPage: number
  limit: number
}): StandardPagination<T> {
  const totalPages = totalItems !== undefined ? Math.ceil(totalItems / limit) : 0

  return new StandardPagination<T>(
    items,
    currentPage,
    limit,
    totalItems || 0,
    totalPages
  )
}